<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QXmlResultItems Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QXmlResultItems Class Reference<br /><sup><sup>[<a href="qtxmlpatterns.html">QtXmlPatterns</a> module]</sup></sup></h1><p>The QXmlResultItems class iterates through the results of
evaluating an <a href="xmlprocessing.html">XQuery</a> in <a href="qxmlquery.html">QXmlQuery</a>. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qxmlresultitems.html#QXmlResultItems">__init__</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlItem <b><a href="qxmlresultitems.html#current">current</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qxmlresultitems.html#hasError">hasError</a></b> (<i>self</i>)</li><li><div class="fn" />QXmlItem <b><a href="qxmlresultitems.html#next">next</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QXmlResultItems class iterates through the results of
evaluating an <a href="xmlprocessing.html">XQuery</a> in <a href="qxmlquery.html">QXmlQuery</a>.</p>
<p>QXmlResultItems presents the evaluation of an associated query
as a sequence of <a href="qxmlitem.html">QXmlItems</a>. The
sequence is traversed by repeatedly calling <a href="qxmlresultitems.html#next">next</a>(), which actually produces the
sequence by lazy evaluation of the query.</p>
<pre class="cpp">
 <span class="type"><a href="qxmlquery.html">QXmlQuery</a></span> query;
 query<span class="operator">.</span>setQuery(<span class="string">"&lt;e/&gt;, 1, 'two'"</span>);
 <span class="type">QXmlResultItems</span> result;

 <span class="keyword">if</span> (query<span class="operator">.</span>isValid()) {
     query<span class="operator">.</span>evaluateTo(<span class="operator">&amp;</span>result);
     <span class="type"><a href="qxmlitem.html">QXmlItem</a></span> item(result<span class="operator">.</span>next());
     <span class="keyword">while</span> (<span class="operator">!</span>item<span class="operator">.</span>isNull()) {
         <span class="comment">// use item</span>
         item <span class="operator">=</span> result<span class="operator">.</span>next();
     }
     <span class="keyword">if</span> (result<span class="operator">.</span>hasError())
         <span class="comment">/* Runtime error! */</span>;
 }
</pre>
<p>An effect of letting <a href="qxmlresultitems.html#next">next</a>() produce the sequence by lazy
evaluation is that a query error can occur on any call to <a href="qxmlresultitems.html#next">next</a>(). If an error occurs, both
<a href="qxmlresultitems.html#next">next</a>() and <a href="qxmlresultitems.html#current">current</a>() will return the null
<a href="qxmlitem.html">QXmlItem</a>, and <a href="qxmlresultitems.html#hasError">hasError</a>() will return
true.</p>
<p>QXmlResultItems can be thought of as an "iterator" that
traverses the sequence of query results once, in the forward
direction. Each call to <a href="qxmlresultitems.html#next">next</a>() advances the iterator to the
next <a href="qxmlitem.html">QXmlItem</a> in the sequence and
returns it, and <a href="qxmlresultitems.html#current">current</a>() always returns the
<a href="qxmlitem.html">QXmlItem</a> that <a href="qxmlresultitems.html#next">next</a>() returned the last time it
was called.</p>
<p><b>Note:</b> When using the QXmlResultItems overload of <a href="qxmlquery.html#evaluateTo">QXmlQuery.evaluateTo</a>() to execute
a query, it is advisable to create a new instance of this class for
each new set of results rather than reusing an old instance.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QXmlResultItems" />QXmlResultItems.__init__ (<i>self</i>)</h3><p>Constructs an instance of <a href="qxmlresultitems.html">QXmlResultItems</a>.</p>


<h3 class="fn"><a name="current" /><a href="qxmlitem.html">QXmlItem</a> QXmlResultItems.current (<i>self</i>)</h3><p>Returns the current item. The current item is the last item that
was produced and returned by <a href="qxmlresultitems.html#next">next</a>().</p>
<p>Returns a null <a href="qxmlitem.html">QXmlItem</a> if there is
no associated <a href="qxmlquery.html">QXmlQuery</a>.</p>


<h3 class="fn"><a name="hasError" />bool QXmlResultItems.hasError (<i>self</i>)</h3><p>If an error occurred during evaluation of the query, true is
returned.</p>
<p>Returns false if query evaluation has been done.</p>


<h3 class="fn"><a name="next" /><a href="qxmlitem.html">QXmlItem</a> QXmlResultItems.next (<i>self</i>)</h3><p>Returns the next result in the sequence produced by lazy
evaluation of the associated query. When the returned <a href="qxmlitem.html">QXmlItem</a> is null, either the evaluation
terminated normally without producing another result, or an error
occurred. Call <a href="qxmlresultitems.html#hasError">hasError</a>() to determine whether
the null item was caused by normal termination or by an error.</p>
<p>Returns a null <a href="qxmlitem.html">QXmlItem</a> if there is
no associated <a href="qxmlquery.html">QXmlQuery</a>.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>